package jjn.effective_java.chapter6.item34;

/**
 * @author Jiang Jining
 * @since 2023-04-26 23:49
 */
public enum PayRollDayV1 {
    MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;
    private static final int MINS_PER_SHIFT = 60 * 8;
    
    int pay(int minutesWorked, int payRate) {
        int basePay = minutesWorked * payRate;
        int overTimePay;
        switch (this) {
            case SATURDAY, SUNDAY -> overTimePay = basePay / 2;
            default ->
                    overTimePay = minutesWorked <= MINS_PER_SHIFT ? 0 : (minutesWorked - MINS_PER_SHIFT) * payRate / 2;
        }
        return basePay + overTimePay;
    }
}
